package com.assembly.system.feign;

import com.assembly.entities.Resources;
import com.assembly.entities.SystemUser;
import com.assembly.feign.IFeignSystemController;
import com.assembly.system.service.IResourcesService;
import com.assembly.system.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FeignSystemController implements IFeignSystemController {

    @Autowired
    private IUserService sysUserService;

    @Autowired
    private IResourcesService resourcesService;

    /**
     * 通过用户名查询用户信息
     * @param username 用户名
     * @return
     */
    @Override
    public SystemUser findUserByUsername(String username,int type) {

        return sysUserService.findUserByAccount(username,type);
    }

    @Override
    public SystemUser findUserByMobile(String mobile,int type) {

        return sysUserService.findUserByMobile(mobile,type);
    }

    @Override
    public SystemUser findUserByOpenid(String openid,int type) {
        return sysUserService.findUserByWxOpenId(openid,type);
    }

    /**
     *通过用户ID查询拥有权限
     * @param userId 用户id
     * @return
     */
    @Override
    public List<Resources> findMenuListByUserId(String userId) {

        return resourcesService.queryResourcesByUserId(userId);
    }
}
